/**
 * @Date 2025/2/26 15:59
 * @Created by 衡盛永
 */

package com.sky.controller.admin;

import com.sky.config.MinioConfig;
import com.sky.result.Result;
import com.sky.utils.MinioUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * CommonController
 */
@RestController
@RequestMapping("/admin/common")
@Api(tags = "上传文件")
@Slf4j
public class CommonController {
    @Resource
    private MinioUtil minioUtil;

    @PostMapping("/upload")
    @ApiOperation("上传文件")
    public Result<String> upload(MultipartFile file) throws Exception {
        String objectName = minioUtil.upload2(file);
        System.out.println("文件上传返回url:" + objectName);
        return Result.success(objectName);
    }
}
